package net.huashitong.brand.dao;

import com.sirdc.modules.core.dao.GenericQuery;
import com.sirdc.modules.core.dao.StringDao;
import com.sirdc.modules.utils.StringUtils;
import net.huashitong.brand.entity.Brands;
import net.huashitong.brand.filter.BrandsFilter;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class BrandsDao extends StringDao<Brands> {

    public List<Brands> query(BrandsFilter filter)
    {
        GenericQuery query = createQuery("obj");
        if (StringUtils.isNotBlank(filter.getBrandName())) {
            query.append(" and obj.brandName like :brandName");
            query.setParam("brandName", StringUtils.getLikewords(filter.getBrandName()));
        }
        return query.listResult(filter);

    }
}
